package file;

import java.io.File;
import java.io.FileFilter;
import java.util.logging.Filter;

public class ListFilesDemo2 {
    public static void main(String[]args){
        File file=new File(".");
        if (file.isDirectory()){
            FileFilter filter=new FileFilter() {
                public boolean accept(File pathname) {
                    String name=pathname.getName();
                    System.out.println(name);
                    return name.endsWith("./txt");
                }
            };
            File[] subs=file.listFiles(filter);
            for (File sub:subs){
                System.out.println(sub.getName());
            }
        }




/*
        File dir=new File(".");
        if (dir.isDirectory()) {
            FileFilter filter = new FileFilter() {
                public boolean accept(File file) {
                   String name=file.getName();
                   return name.endsWith(".txt");
                }
            };

            File[] subs=dir.listFiles(filter);
            for (File sub:subs){
                System.out.println(sub.getName());
            }

        }
 */
    }
}
